package org.ttitfly.ttcore.system;

import javax.servlet.ServletContextEvent;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;



/**
 * 平台初始化类
 */
public class InitPlatformLoader extends ContextLoaderListener {
	protected final Log logger = LogFactory.getLog(getClass());

	public void contextInitialized(ServletContextEvent event) {
		logger.info("初始化平台...");
		super.contextInitialized(event);
		String path = event.getServletContext().getRealPath("/");
		logger.debug("系统部署根路径:" + path);
		Platform.getInstance().setWebPath(path);
		// 初始化Support中Spring的CTX
		ApplicationContext ctx = WebApplicationContextUtils
			.getRequiredWebApplicationContext(event.getServletContext());
		Platform.getInstance().setApplicationContext(ctx);
		
	    
		logger.info("初始化完成...");
	}
}
